using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities
{
    /// <summary>
    /// 工作流版本实体，存储每次发布/保存的版本化定义
    /// </summary>
    [Table("workflow_versions")]
    public class WorkflowVersion : ITenantEntity
    {
        [Key]
        public long Id { get; set; }

        [Required]
        public long WorkflowId { get; set; }

        /// <summary>
        /// 版本序号，从 1 递增
        /// </summary>
        [Required]
        public int Version { get; set; }

        /// <summary>
        /// 版本标签（可选，如 v1.0.0）
        /// </summary>
        [StringLength(50)]
        public string? Tag { get; set; }

        /// <summary>
        /// 步骤定义快照
        /// </summary>
        [Column(TypeName = "json")]
        public string Steps { get; set; } = string.Empty;

        /// <summary>
        /// 条件定义快照
        /// </summary>
        [Column(TypeName = "json")]
        public string Conditions { get; set; } = string.Empty;

        /// <summary>
        /// 版本说明
        /// </summary>
        [StringLength(500)]
        public string? Description { get; set; }

        /// <summary>
        /// 创建者
        /// </summary>
        public long CreatedBy { get; set; }

        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 租户标识符
        /// </summary>
        public string TenantId { get; set; } = string.Empty;
    }
}
